#pragma once
#include <iostream>    
#include <climits>    
#include <vector>    
using namespace std;


namespace BLZ
{
    template <size_t N>
    class bitset
    {
    private:
        std::vector<char> v;
    public:
        bitset() :
            v((N + 7) / 8, 0)
        {
            // v.resize(N / 8 + (bool)(N / 8.0));    
            // v.resize((N + 7) / 8);    
        }
        void set(unsigned int n)
        {
            size_t i = n / 8;
            size_t j = n % 8;
            v[i] |= (1 << j);
        }
        void reset(unsigned int n)
        {
            size_t i = n / 8;
            size_t j = n % 8;
            v[i] &= (~(1 << j));
        }
        bool test(unsigned int n)
        {
            size_t i = n / 8;
            size_t j = n % 8;
            return (v[i] & (1 << j));
        }
    };
    template <size_t N>
    class DoubleBS
    {
    private:
        BLZ::bitset<N> _bs1;
        BLZ::bitset<N> _bs2;
    public:
        void set(unsigned int n)
        {
            if (!_bs1.test(n) && !_bs2.test(n))
            {
                _bs2.set(n);
            }
            else if (!_bs1.test(n) && _bs2.test(n))
            {
                _bs1.set(n);
                _bs2.reset(n);
            }
            else if (_bs1.test(n) && !_bs2.test(n))
            {
                _bs2.set(n);
            }
        }
        int test(unsigned int n)
        {
            if (!_bs1.test(n) && !_bs2.test(n))
            {
                return 0;
            }
            else if (!_bs1.test(n) && _bs2.test(n))
            {
                return 1;
            }
            else if (_bs1.test(n) && !_bs2.test(n))
            {
                return 2;
            }
            else
            {
                return 3;
            }
        }
    };
}

vector<int> fun1()
{
    vector<int> ret = {};
    BLZ::DoubleBS<(unsigned int)-1> dbs;
    unsigned long long i = 0;
    int temp = 0;
    for (; i < 10000000000; i++)
    {
        cin >> temp;
        dbs.set(temp);
    }
    for (i = 0; i < (unsigned int)-1; i++)
    {
        if (dbs.test(i) <= 2)
        {
            ret.push_back(i);
        }
    }
    return ret;
}